<html>
<head><meta charset="utf-8"><title>format_args! accept u8 and char · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html">format_args! accept u8 and char</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="206450305"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206450305" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206450305">(Aug 10 2020 at 11:22)</a>:</h4>
<p>If a code base have a bunch of <code>write!</code> but some parts only need to write one character or one byte, to keep consistency with the code base, one would usually do <code>write!(buf, "a")</code> which results in slightly worse generated code. I wonder if we should allow <code>char</code> and <code>u8</code> as input to <code>format_args!</code> to allow that?</p>



<a name="206450329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206450329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206450329">(Aug 10 2020 at 11:23)</a>:</h4>
<p>Why not just fix the generated code?</p>



<a name="206451205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206451205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206451205">(Aug 10 2020 at 11:36)</a>:</h4>
<p>Generated code is fixed in <a href="https://github.com/rust-lang/rust/pull/75358">https://github.com/rust-lang/rust/pull/75358</a> only without extra arguments.</p>



<a name="206451237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206451237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206451237">(Aug 10 2020 at 11:37)</a>:</h4>
<p>But I think the generated code to write a single byte, single char and str is different. I didn't check and maybe I am wrong.</p>



<a name="206451260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206451260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206451260">(Aug 10 2020 at 11:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="211727">Jonas Schievink</span> <a href="#narrow/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char/near/206450329">said</a>:</p>
<blockquote>
<p>Why not just fix the generated code?</p>
</blockquote>
<p><span class="user-mention" data-user-id="209117">@lzutao</span> is it possible?</p>



<a name="206451998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206451998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206451998">(Aug 10 2020 at 11:50)</a>:</h4>
<p>byte, char, and str are all different things though, so they should end up with different code</p>



<a name="206452172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206452172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206452172">(Aug 10 2020 at 11:52)</a>:</h4>
<p>I don't think it's possible to fix the underlying efficiency problems (with or without adding new surface features to <code>format_args!</code>) without changing what it expands to, and thus the implementation of <code>core::fmt::Arguments</code></p>



<a name="206452216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206452216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206452216">(Aug 10 2020 at 11:53)</a>:</h4>
<p>That is totally something I'd like to see, but also a large amount of work (for example, to ensure the generated code stays simple enough to not regress compile times)</p>



<a name="206464608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206464608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206464608">(Aug 10 2020 at 14:10)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> Do you think adding support for <code>char</code> and <code>u8</code> a good idea or do you have anything in mind to let the user easily optimize it?</p>



<a name="206464656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206464656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206464656">(Aug 10 2020 at 14:11)</a>:</h4>
<p>I don't see how that would be implemented in a way that's faster than what we have now</p>



<a name="206464694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206464694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206464694">(Aug 10 2020 at 14:11)</a>:</h4>
<p>But currently char and byte is probably faster than str. So why not?</p>



<a name="206464716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206464716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206464716">(Aug 10 2020 at 14:11)</a>:</h4>
<p><code>format_args!("{}", some_u8)</code> should already compile down to filling a <code>core::fmt::Arguments</code> with just the formatting of the <code>u8</code></p>



<a name="206464747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206464747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206464747">(Aug 10 2020 at 14:11)</a>:</h4>
<p>Oh, so it is the same as using bytes and chars?</p>



<a name="206464826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206464826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206464826">(Aug 10 2020 at 14:12)</a>:</h4>
<p>It should be?</p>



<a name="206464881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206464881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206464881">(Aug 10 2020 at 14:12)</a>:</h4>
<p>Well in any case, the first step should be to actually find out that this is currently too slow and would be improved by your change</p>



<a name="206464917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206464917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206464917">(Aug 10 2020 at 14:13)</a>:</h4>
<p>Oh, you mean when you want to write a raw <code>u8</code> to the writer?</p>



<a name="206464966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206464966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206464966">(Aug 10 2020 at 14:13)</a>:</h4>
<p>That shouldn't go through <code>format_args!</code> at all, it's meant for UTF-8 data only</p>



<a name="206465251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206465251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206465251">(Aug 10 2020 at 14:15)</a>:</h4>
<p>I meant it may be good to use <code>write!()</code> for everywhere for consistency, leaving some place for <code>write_char</code> may look weird, <code>write!()</code> is a macro so it can be tuned to handle raw <code>u8</code> too, or just a single <code>char</code>.</p>



<a name="206465321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206465321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206465321">(Aug 10 2020 at 14:16)</a>:</h4>
<p>But yes, the changes may be in <code>write!()</code> but not in <code>format_args!()</code>.</p>



<a name="206465429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206465429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206465429">(Aug 10 2020 at 14:17)</a>:</h4>
<p>I don't think that change makes sense, but the libs team would have to decide on this</p>



<a name="206487023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206487023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206487023">(Aug 10 2020 at 17:16)</a>:</h4>
<p>I don't think that the <code>write!</code> macro should accept things that aren't strings, because that would make it less type safe to use.</p>



<a name="206487051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206487051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206487051">(Aug 10 2020 at 17:16)</a>:</h4>
<p>I do, however, think that there should be easier ways to work with bytes.</p>



<a name="206487246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206487246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206487246">(Aug 10 2020 at 17:18)</a>:</h4>
<p>If you want something that automatically figures out what you have, you could define a trait for the things you want to write. That would be application-specific though.</p>



<a name="206540994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206540994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206540994">(Aug 11 2020 at 05:16)</a>:</h4>
<p>Should we move this discussion to <a class="stream" data-stream-id="219381" href="/#narrow/stream/219381-t-libs">#t-libs</a>?</p>



<a name="206541016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206541016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206541016">(Aug 11 2020 at 05:17)</a>:</h4>
<p><code>write!</code> is a macro and I think it should accepts stuff that is writable, rather that just strictly strings. It can improve readability a lot and gives performance boost with little change, like how those find and replace <code>Pattern</code> API is.</p>



<a name="206541709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206541709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206541709">(Aug 11 2020 at 05:36)</a>:</h4>
<p>I know that it <em>can</em>. But I'm not sure it should.</p>



<a name="206541783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206541783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206541783">(Aug 11 2020 at 05:38)</a>:</h4>
<p>I would love to have a <code>write_bytes!</code>. Usually I just call <code>.write_all</code> though.</p>



<a name="206543250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206543250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206543250">(Aug 11 2020 at 06:13)</a>:</h4>
<p>I think it <em>can</em> and it <em>should</em>.</p>



<a name="206543348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206543348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206543348">(Aug 11 2020 at 06:15)</a>:</h4>
<p>But I don't mean using it for <code>&amp;[u8]</code>, I am just saying a single <code>char</code> and <code>u8</code>. Either way, I don't have much opinion on writing bytes but it would be good to have that.</p>



<a name="206544774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206544774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206544774">(Aug 11 2020 at 06:47)</a>:</h4>
<p>Are you talking about a literal, or an arbitrary expression of that type?</p>



<a name="206544823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206544823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206544823">(Aug 11 2020 at 06:48)</a>:</h4>
<p>If the former, that's not <em>too</em> harmful, but it doesn't seem all that helpful either.</p>



<a name="206544847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206544847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206544847">(Aug 11 2020 at 06:49)</a>:</h4>
<p>If the latter, that would reduce the compiler's ability to give good errors.</p>



<a name="206544861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206544861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206544861">(Aug 11 2020 at 06:49)</a>:</h4>
<p>(Also, in the case of a u8, that should only work with io, not fmt, but <code>write!</code> normally works with both.)</p>



<a name="206581429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206581429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206581429">(Aug 11 2020 at 14:25)</a>:</h4>
<p>I mean something like <code>write!(buf, 'a')</code> or <code>write!(buf, b'a')</code>.</p>



<a name="206582420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206582420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206582420">(Aug 11 2020 at 14:33)</a>:</h4>
<p>Perf is nice bonus it we can get, however <code>write!</code> macro is for easy, not performance.<br>
When it come down to perf, one should use specialized methods.</p>



<a name="206585594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206585594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206585594">(Aug 11 2020 at 14:58)</a>:</h4>
<p><span class="user-mention" data-user-id="209117">@lzutao</span>  that's not the usual "bending the curve" Rust talk <span aria-label="wink" class="emoji emoji-1f609" role="img" title="wink">:wink:</span></p>



<a name="206586401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206586401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206586401">(Aug 11 2020 at 15:05)</a>:</h4>
<p>thanks for the pointer. Never saw that talk before.</p>



<a name="206700439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206700439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206700439">(Aug 12 2020 at 14:22)</a>:</h4>
<p>Well, why not we call it easy performance? It still remains easy, more to that it gets more performance easy too.</p>



<a name="206701314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206701314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206701314">(Aug 12 2020 at 14:29)</a>:</h4>
<p>I don't see how. Macros don't have way to overload its inputs AFAIK.</p>



<a name="206701469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206701469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206701469">(Aug 12 2020 at 14:30)</a>:</h4>
<p>Unless you want another separate macro. But in that case why not use specialized methods though.</p>



<a name="206701628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206701628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206701628">(Aug 12 2020 at 14:31)</a>:</h4>
<p>Oh, let me think. <code>write!</code> expands to <code>Arguments::new_v1</code>. Maybe we could generic its arguments there.</p>



<a name="206897503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/206897503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pickfire <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#206897503">(Aug 14 2020 at 04:35)</a>:</h4>
<p>Good idea. But does anyone from the libs team think this is a good idea?</p>



<a name="207508480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/format_args%21%20accept%20u8%20and%20char/near/207508480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/format_args!.20accept.20u8.20and.20char.html#207508480">(Aug 20 2020 at 10:31)</a>:</h4>
<p>(you may want to ask in <a class="stream" data-stream-id="219381" href="/#narrow/stream/219381-t-libs">#t-libs</a>)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>